package com.ruoyi.web.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.im.service.YytImJoinupService;
import com.ruoyi.common.im.service.YytImMessageService;
import com.ruoyi.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 即时通讯-消息 前端控制器
 * </p>
 *
 * @author MrPing
 * @since 2022-08-23
 */
@RestController
@RequestMapping("/message")
public class YytImMessageController {

    @Autowired
    private YytImMessageService yytImMessageService;

    @Autowired
    private YytImJoinupService yytImJoinupService;


    /**
     * 获取聊天页面数据
     * @param pageNum  当前页
     * @param pageSize 页数大小
     * @param fromId   发送者id
     * @param toId     接受者id
     * @param type     发送场景【0 -> 用户对接客服， 1 -> 客服对接客服， 2 -> 客服查看聊天记录】
     * @return
     */
    @GetMapping("/getMessageList")
    public ResponseResult getMessageList(@RequestParam("pageNum") Integer pageNum,
                                         @RequestParam("pageSize") Integer pageSize,
                                         @RequestParam("fromId") String fromId,
                                         @RequestParam("toId") String toId,
                                         @RequestParam("type") Integer type) {


        return  ResponseResult.success(yytImMessageService.getMessageList(new Page<>(pageNum, pageSize), fromId, toId, type));

    }


}
